﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ExaminationSys.DataAccess.Entity;
using ExaminationSys.Helper;
using Ext.Net;

namespace ExaminationSys.View.News
{
    public partial class ExpressInfoSearchWindow : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public Store GridStore { get; set; }
        public static Action<PageEntity> SearchFun;

        public void Show(Action<PageEntity> _SearchFun)
        {
            SearchFun = _SearchFun;
            this.ExpressInfoSearch.Show();
            
        }

        protected void SearchExpressInfo(object sender, DirectEventArgs e)
        {
            string sqlWhere = " NewsTypeName='信息快递'";
            if (!string.IsNullOrWhiteSpace(ExpressInfoTitle.Text))
            {
                var title = ExpressInfoTitle.Text;
                title = title.SqlSafe();
                sqlWhere += string.Format(" AND Title like '%{0}%'", title);
            }

            if (RadioAll.Checked)
                sqlWhere += " and status<>0";
            else if (RadioYes.Checked)
                sqlWhere += " and status=1";
            else if (RadioNo.Checked)
            {

                sqlWhere += " and status=2";
            }

            if (RadRecommendY.Checked)
                sqlWhere += " and IsRecommend='true'";
            else if (RadRecommendN.Checked)
                sqlWhere += " and IsRecommend='false'";


            PageEntity pageEntity=new PageEntity();
            pageEntity.SqlWhere = sqlWhere;
            SearchFun.Invoke(pageEntity);
            GridStore.Reload();
            ExpressInfoSearch.Hide();
        }
    }
}